home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / include / aout.h next >
C/C++ Source or Header  |  1996-01-30  |  8KB  |  271 lines

  1. /* This file may have been modified by DJ Delorie (Jan 1991).  If so,
  2. ** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave,
  3. ** Rochester NH, 03867-2954, USA.
  4. */
  5.  
  6. #ifndef __A_OUT_GNU_H__
  7. #define __A_OUT_GNU_H__
  8.  
  9. #define __GNU_EXEC_MACROS__
  10.  
  11. typedef struct gnu_aout {
  12.     unsigned long info;
  13.     unsigned long tsize;
  14.     unsigned long dsize;
  15.     unsigned long bsize;
  16.     unsigned long symsize;
  17.     unsigned long entry;
  18.     unsigned long txrel;
  19.     unsigned long dtrel;
  20.     } GNU_AOUT;
  21.  
  22. #ifndef __STRUCT_EXEC_OVERRIDE__
  23.  
  24. struct exec
  25. {
  26.   unsigned long a_info;         /* Use macros N_MAGIC, etc for access */
  27.   unsigned a_text;              /* length of text, in bytes */
  28.   unsigned a_data;              /* length of data, in bytes */
  29.   unsigned a_bss;               /* length of uninitialized data area for file, in bytes */
  30.   unsigned a_syms;              /* length of symbol table data in file, in bytes */
  31.   unsigned a_entry;             /* start address */
  32.   unsigned a_trsize;            /* length of relocation info for text, in bytes */
  33.   unsigned a_drsize;            /* length of relocation info for data, in bytes */
  34. };
  35.  
  36. #endif /* __STRUCT_EXEC_OVERRIDE__ */
  37.  
  38. /* these go in the N_MACHTYPE field */
  39. enum machine_type {
  40. #if defined (M_OLDSUN2)
  41.   M__OLDSUN2 = M_OLDSUN2,
  42. #else
  43.   M_OLDSUN2 = 0,
  44. #endif
  45. #if defined (M_68010)
  46.   M__68010 = M_68010,
  47. #else
  48.   M_68010 = 1,
  49. #endif
  50. #if defined (M_68020)
  51.   M__68020 = M_68020,
  52. #else
  53.   M_68020 = 2,
  54. #endif
  55. #if defined (M_SPARC)
  56.   M__SPARC = M_SPARC,
  57. #else
  58.   M_SPARC = 3,
  59. #endif
  60.   /* skip a bunch so we don't run into any of sun's numbers */
  61.   M_386 = 100,
  62. };
  63.  
  64. #if !defined (N_MAGIC)
  65. #define N_MAGIC(exec) ((exec).a_info & 0xffff)
  66. #endif
  67. #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
  68. #define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
  69. #define N_SET_INFO(exec, magic, type, flags) \
  70.         ((exec).a_info = ((magic) & 0xffff) \
  71.          | (((int)(type) & 0xff) << 16) \
  72.          | (((flags) & 0xff) << 24))
  73. #define N_SET_MAGIC(exec, magic) \
  74.         ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
  75.  
  76. #define N_SET_MACHTYPE(exec, machtype) \
  77.         ((exec).a_info = \
  78.          ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
  79.  
  80. #define N_SET_FLAGS(exec, flags) \
  81.         ((exec).a_info = \
  82.          ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
  83.  
  84. /* Code indicating object file or impure executable.  */
  85. #define OMAGIC 0407
  86. /* Code indicating pure executable.  */
  87. #define NMAGIC 0410
  88. /* Code indicating demand-paged executable.  */
  89. #define ZMAGIC 0413
  90.  
  91. #if !defined (N_BADMAG)
  92. #define N_BADMAG(x)                                     \
  93.  (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC          \
  94.   && N_MAGIC(x) != ZMAGIC)
  95. #endif
  96.  
  97. #define _N_BADMAG(x)                                    \
  98.  (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC          \
  99.   && N_MAGIC(x) != ZMAGIC)
  100.  
  101. #define _N_HDROFF(x) 0
  102.  
  103. #if !defined (N_TXTOFF)
  104. #define N_TXTOFF(x) \
  105.  (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : sizeof (struct exec))
  106. #endif
  107.  
  108. #if !defined (N_DATOFF)
  109. #define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
  110. #endif
  111.  
  112. #if !defined (N_TRELOFF)
  113. #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
  114. #endif
  115.  
  116. #if !defined (N_DRELOFF)
  117. #define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)
  118. #endif
  119.  
  120. #if !defined (N_SYMOFF)
  121. #define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)
  122. #endif
  123.  
  124. #if !defined (N_STROFF)
  125. #define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms)
  126. #endif
  127.  
  128. /* Address of text segment in memory after it is loaded.  */
  129. #if !defined (N_TXTADDR)
  130. #define N_TXTADDR(x) (sizeof(struct exec)+4096)
  131. #endif
  132.  
  133. /* Address of data segment in memory after it is loaded.
  134.    Note that it is up to you to define SEGMENT_SIZE
  135.    on machines not listed here.  */
  136. #ifdef i386
  137. #define SEGMENT_SIZE 0x400000
  138. #endif
  139. #if defined(vax) || defined(hp300) || defined(pyr)
  140. #define SEGMENT_SIZE page_size
  141. #endif
  142. #ifdef  sony
  143. #define SEGMENT_SIZE    0x2000
  144. #endif  /* Sony.  */
  145. #ifdef is68k
  146. #define SEGMENT_SIZE 0x20000
  147. #endif
  148. #if defined(m68k) && defined(PORTAR)
  149. #define PAGE_SIZE 0x400
  150. #define SEGMENT_SIZE PAGE_SIZE
  151. #endif
  152.  
  153. #ifndef N_DATADDR
  154. #define N_DATADDR(x) \
  155.     (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) \
  156.      : (SEGMENT_SIZE + ((N_TXTADDR(x)+(x).a_text-1) & ~(SEGMENT_SIZE-1))))
  157. #endif
  158.  
  159. /* Address of bss segment in memory after it is loaded.  */
  160. #if !defined (N_BSSADDR)
  161. #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
  162. #endif
  163.  
  164. #if !defined (N_NLIST_DECLARED)
  165. struct nlist {
  166.   union {
  167.     char *n_name;
  168.     struct nlist *n_next;
  169.     long n_strx;
  170.   } n_un;
  171.   unsigned char n_type;
  172.   char n_other;
  173.   short n_desc;
  174.   unsigned long n_value;
  175. };
  176. #endif /* no N_NLIST_DECLARED.  */
  177.  
  178. #if !defined (N_UNDF)
  179. #define N_UNDF 0
  180. #endif
  181. #if !defined (N_ABS)
  182. #define N_ABS 2
  183. #endif
  184. #if !defined (N_TEXT)
  185. #define N_TEXT 4
  186. #endif
  187. #if !defined (N_DATA)
  188. #define N_DATA 6
  189. #endif
  190. #if !defined (N_BSS)
  191. #define N_BSS 8
  192. #endif
  193. #if !defined (N_FN)
  194. #define N_FN 15
  195. #endif
  196.  
  197. #if !defined (N_EXT)
  198. #define N_EXT 1
  199. #endif
  200. #if !defined (N_TYPE)
  201. #define N_TYPE 036
  202. #endif
  203. #if !defined (N_STAB)
  204. #define N_STAB 0340
  205. #endif
  206.  
  207. /* The following type indicates the definition of a symbol as being
  208.    an indirect reference to another symbol.  The other symbol
  209.    appears as an undefined reference, immediately following this symbol.
  210.  
  211.    Indirection is asymmetrical.  The other symbol's value will be used
  212.    to satisfy requests for the indirect symbol, but not vice versa.
  213.    If the other symbol does not have a definition, libraries will
  214.    be searched to find a definition.  */
  215. #define N_INDR 0xa
  216.  
  217. /* The following symbols refer to set elements.
  218.    All the N_SET[ATDB] symbols with the same name form one set.
  219.    Space is allocated for the set in the text section, and each set
  220.    element's value is stored into one word of the space.
  221.    The first word of the space is the length of the set (number of elements).
  222.  
  223.    The address of the set is made into an N_SETV symbol
  224.    whose name is the same as the name of the set.
  225.    This symbol acts like a N_DATA global symbol
  226.    in that it can satisfy undefined external references.  */
  227.  
  228. /* These appear as input to LD, in a .o file.  */
  229. #define N_SETA  0x14            /* Absolute set element symbol */
  230. #define N_SETT  0x16            /* Text set element symbol */
  231. #define N_SETD  0x18            /* Data set element symbol */
  232. #define N_SETB  0x1A            /* Bss set element symbol */
  233.  
  234. /* This is output from LD.  */
  235. #define N_SETV  0x1C            /* Pointer to set vector in data area.  */
  236.  
  237. #if !defined (N_RELOCATION_INFO_DECLARED)
  238. /* This structure describes a single relocation to be performed.
  239.    The text-relocation section of the file is a vector of these structures,
  240.    all of which apply to the text section.
  241.    Likewise, the data-relocation section applies to the data section.  */
  242.  
  243. struct relocation_info
  244. {
  245.   /* Address (within segment) to be relocated.  */
  246.   int r_address;
  247.   /* The meaning of r_symbolnum depends on r_extern.  */
  248.   unsigned int r_symbolnum:24;
  249.   /* Nonzero means value is a pc-relative offset
  250.      and it should be relocated for changes in its own address
  251.      as well as for changes in the symbol or section specified.  */
  252.   unsigned int r_pcrel:1;
  253.   /* Length (as exponent of 2) of the field to be relocated.
  254.      Thus, a value of 2 indicates 1<<2 bytes.  */
  255.   unsigned int r_length:2;
  256.   /* 1 => relocate with value of symbol.
  257.           r_symbolnum is the index of the symbol
  258.           in file's the symbol table.
  259.      0 => relocate with the address of a segment.
  260.           r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
  261.           (the N_EXT bit may be set also, but signifies nothing).  */
  262.   unsigned int r_extern:1;
  263.   /* Four bits that aren't used, but when writing an object file
  264.      it is desirable to clear them.  */
  265.   unsigned int r_pad:4;
  266. };
  267. #endif /* no N_RELOCATION_INFO_DECLARED.  */
  268.  
  269.  
  270. #endif /* __A_OUT_GNU_H__ */
  271.